home *** CD-ROM | disk | FTP | other *** search
- OPT PREPROCESS
-
- MODULE 'graphics/gfx','graphics/rastport',
- 'feelin','libraries/feelin','a4'
-
- -> Here is the beginning of our simple new class...
-
- CONST FM_Strobo = FCCM_BASE
-
- OBJECT localobjectdata
- signalhandler:feelinSignalHandler
- ENDOBJECT
-
- PROC main()
- DEF c,w,
- fcc:PTR TO feelinClass
-
- sys_SGlob()
-
- IF feelinbase := OpenLibrary('feelin.library',FV_VERSION)
-
- /*
- Create the new custom class with a call to F_CreateClass().
-
- This function returns a feelinClass structure. You must use class.id as ID
- to create instance of your custom class. This ID is unique and made by
- F_CreateClass() when ID is NIL.
- */
-
- IF fcc := F_CreateClassA([FA_SuperID, FC_Area,
- FA_DataSize, SIZEOF localobjectdata,
- FA_Dispatcher, {myDispatcher},
- NIL])
- c := ClientObject,
- FA_Client_Title, 'Class2',
- FA_Client_Version, '$VER: Class2 0.02 (22.10.01)',
- FA_Client_Copyright, '© 2001 by Laviale Olivier',
- FA_Client_Author, 'Laviale Olivier (lotan9@aol.com)',
- FA_Client_Description, 'Tutorial on Client.AddInputHandler()',
- FA_Client_Base, 'CLASS2',
-
- Child, w := WindowObject, FA_Window_Title, 'Crazy colors using Client.AddInputHandler()', FA_ID, "CLS2",
- Child, VGroup,
- Child, HGroup,
- Child, F_NewObjA(fcc.id,[GaugeFrame, DontChain, NIL]),
- Child, F_NewObjA(fcc.id,[GaugeFrame, DontChain, NIL]),
- End,
-
- Child, HGroup,
- Child, F_NewObjA(fcc.id,[GaugeFrame, DontChain, NIL]),
- Child, F_NewObjA(fcc.id,[GaugeFrame, DontChain, NIL]),
- End,
- End,
- End,
- End
-
- IF c
- F_DoA(w,FM_Notify,[FA_Window_CloseRequest,TRUE, c,2,FM_Client_ReturnID,FV_Client_Quit])
- F_Set(w,FA_Window_Open,TRUE)
-
- F_DoA(c,FM_Client_Run,NIL)
-
- F_DisposeObj(c)
- ENDIF
-
- F_RemoveClass(fcc)
- ELSE
- WriteF('Unable to create custom class.\n')
- ENDIF
-
- CloseLibrary(feelinbase)
- ELSE
- WriteF('Failed to open feelin.library.\n')
- ENDIF
- ENDPROC
-
- PROC myDispatcher(cl=A2:PTR TO feelinClass,obj=A0:PTR TO feelinObject,method=D0,args=A1:PTR TO LONG)
- DEF data:PTR TO localobjectdata
-
- sys_RGlob() ; data := INST_DATA(cl,obj)
- /*
- Here comes the dispatcher for our custom class. Unknown/unused methods are
- passed to the superclass immediately.
- */
-
- SELECT method
- CASE FM_New ; RETURN mNew (cl,obj,data,args)
-
- CASE FM_Show ; RETURN mShow (cl,obj,data)
- CASE FM_Hide ; mHide (cl,obj,data)
- CASE FM_AskMinMax ; RETURN mAskMinMax (cl,obj)
- CASE FM_Draw ; RETURN mDraw (cl,obj,args)
-
- CASE FM_Strobo ; RETURN F_Draw(obj,FF_Draw_Update) BUT TRUE
-
- DEFAULT ; RETURN F_SuperDoA(cl,obj,method,args)
- ENDSELECT
- ENDPROC
-
- PROC mNew(cl,obj:PTR TO feelinObject,data:PTR TO localobjectdata,args)
- data.signalhandler.object := obj
- data.signalhandler.method := FM_Strobo
- data.signalhandler.flags := FF_SignalHandler_Timer
- data.signalhandler.secs := 0
- data.signalhandler.micros := 30000
- ENDPROC F_SuperDoA(cl,obj,FM_New,args)
- PROC mAskMinMax(cl,obj:PTR TO feelinObject)
- /*
- AskMinMax method will be called before the window is opened and before
- layout takes place. We need to tell Feelin the minimum and maximum size of
- our object. Note that we indeed need to *add* these values, not just set
- them !
- */
-
- _minw(obj) += 30
- _minh(obj) += 30
-
- /*
- Now call our superclass. Area.fcc will handle everything, taking care of
- FA_FixedXxx, FA_MinXxx and FA_MaxXxx.
- */
-
- F_SuperDoA(cl,obj,FM_AskMinMax,NIL)
- ENDPROC
- PROC mDraw(cl,obj:PTR TO feelinObject,d:PTR TO FS_Draw)
- /*
- Draw method is called whenever Feelin feels (obviously ;-)) we should
- render our object. This usually happens after layout is finished. Note: You
- may only render within the rectangle _mleft(obj), _mtop(obj), _mwidth(obj),
- _mheight(obj).
- */
-
- DEF rp:PTR TO rastport
-
- rp := _rp(obj)
-
- /*
- let our superclass draw itself first, Area class would e.g. draw the frame
- and clear the whole region. What it does exactly depends on flags.
- */
-
- F_SuperDoA(cl,obj,FM_Draw,d)
-
- _APen(Rnd(1 << rp.bitmap.depth) - 1)
- _Boxf(_mx(obj),_my(obj),_mx2(obj),_my2(obj))
- ENDPROC
- PROC mShow(cl,obj:PTR TO feelinObject,data:PTR TO localobjectdata)
- DEF sh
-
- F_SuperDoA(cl,obj,FM_Show,NIL)
- F_DoA(_client(obj),FM_Client_AddSignalHandler,(sh := data.signalhandler) BUT {sh})
- ENDPROC
- PROC mHide(cl:PTR TO feelinClass,obj:PTR TO feelinObject,data:PTR TO localobjectdata)
- DEF sh
-
- F_DoA(_client(obj),FM_Client_RemSignalHandler,(sh := data.signalhandler) BUT {sh})
- F_SuperDoA(cl,obj,FM_Hide,NIL)
- ENDPROC
-